Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (sink: aws_cloudwatch_logs) #11185: Allow specifying a KMS key and tags for newly created AWS CloudWatch log groups. #22274

Conversation

johannesfloriangeiger
Copy link
Contributor

@johannesfloriangeiger johannesfloriangeiger commented Jan 22, 2025

Summary

Implements the feature request #11185 by allowing users to specify a KMS key and tags for AWS CloudWatch log group sinks that are being used when creating new groups.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

  • New integration test is provided in the PR.
  • Manually
    • Get yourself an AWS environment.
    • Create a new KMS key and make sure that key can be used to encrypt CloudWatch log groups (for an example Key policy snippet see below).
    • Create a Vector config file as seen below, replace $KMS_KEY with the ARN of the key created in the previous step.
    • Run Vector: vector --config ./vector.yaml, see 3 new log groups being created: One without both custom KMS key and tags, one with only tags and one with both custom KMS key and tags.

Key policy that allows the usage in log groups in us-east-1:

{
  "Sid": "Allow use of the key for CloudWatch",
  "Effect": "Allow",
  "Principal": {
    "Service": "logs.us-east-1.amazonaws.com"
  },
  "Action": [
    "kms:Encrypt",
    "kms:Decrypt",
    "kms:ReEncrypt*",
    "kms:GenerateDataKey*",
    "kms:DescribeKey"
  ],
  "Resource": "*"
}

vector.yaml

sources:
  demo_logs:
    type: demo_logs
    format: json
sinks:
  cloudwatch_logs_without:
    type: aws_cloudwatch_logs
    inputs: [demo_logs]
    group_name: /without
    stream_name: demo-stream
    encoding:
      codec: json
  cloudwatch_logs_standard:
    type: aws_cloudwatch_logs
    inputs: [demo_logs]
    group_name: /standard
    stream_name: demo-stream
    encoding:
      codec: json
    tags:
      type: standard
  cloudwatch_logs_custom_kms_key:
    type: aws_cloudwatch_logs
    inputs: [demo_logs]
    group_name: /with-kms
    stream_name: demo-stream
    encoding:
      codec: json
    kms_key: $KMS_KEY
    tags:
      type: kms-key

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

  • Please read our Vector contributor resources.
    • make check-all is a good command to run locally. This check is
      defined here. Some of these
      checks might not be relevant to your PR. For Rust changes, at the very least you should run:
      • cargo fmt --all
      • cargo clippy --workspace --all-targets -- -D warnings
      • cargo nextest run --workspace (alternatively, you can run cargo test --all)
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run dd-rust-license-tool write to regenerate the license inventory and commit the changes (if any). More details here.

References

@bits-bot
Copy link

bits-bot commented Jan 22, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added domain: sinks Anything related to the Vector's sinks domain: ci Anything related to Vector's CI environment labels Jan 22, 2025
@johannesfloriangeiger johannesfloriangeiger marked this pull request as ready for review January 23, 2025 14:57
@johannesfloriangeiger johannesfloriangeiger requested a review from a team as a code owner January 23, 2025 14:57
Copy link
Member

@pront pront left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, this looks good and thank you for adding tests.

src/sinks/aws_cloudwatch_logs/config.rs Show resolved Hide resolved
@johannesfloriangeiger johannesfloriangeiger requested review from a team as code owners January 24, 2025 18:32
@github-actions github-actions bot added the domain: external docs Anything related to Vector's external, public documentation label Jan 24, 2025
Cargo.lock Outdated Show resolved Hide resolved
Copy link
Member

@pront pront left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs team left a comment. Otherwise, LGTM

@johannesfloriangeiger johannesfloriangeiger changed the title #11185: Allow specifying a KMS key and tags for newly created AWS CloudWatch log groups. feat (sink: aws_cloudwatch_logs) #11185: Allow specifying a KMS key and tags for newly created AWS CloudWatch log groups. Jan 26, 2025
@pront pront enabled auto-merge January 27, 2025 18:43
@pront pront added this pull request to the merge queue Jan 27, 2025
Merged via the queue into vectordotdev:master with commit f151cab Jan 27, 2025
87 of 88 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: ci Anything related to Vector's CI environment domain: external docs Anything related to Vector's external, public documentation domain: sinks Anything related to the Vector's sinks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow setting KMS key id and tags when creating a CloudWatch log group
4 participants